package cn.sccdlg.crawler.job.controller;

import cn.sccdlg.crawler.job.pojo.JobResult;
import cn.sccdlg.crawler.job.service.JobRepositoryService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author RaoShuang
 * @emil 991207823@qq.com
 * @date 2020/12/10 20:50
 * 查询ES控制器
 */
@RestController
public class SearchController {
    private static final Logger log = LoggerFactory.getLogger(SearchController.class);

    @Autowired
    private JobRepositoryService jobRepositoryService;

    /**
     * 根据条件分页查询数据
     * @param salary 薪资
     * @param jobaddr 工作地点
     * @param keyword 关键字
     * @param page 页码
     * @return
     */
    @PostMapping(value = "search")
    public JobResult search(String salary, String jobaddr, String keyword, Integer page) {
        JobResult jobResult = this.jobRepositoryService.search2(salary, jobaddr, keyword, page);
        String toString = jobResult.toString();
        log.info(toString);
        return jobResult;
    }
}
